
package de.carcophan.jimdb.ejb.entites.service;

import de.carcophan.jimdb.ejb.entites.Status;
import java.io.Serializable;
import javax.annotation.security.RolesAllowed;
import javax.ejb.Stateful;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;


@Stateful
public class StatusFacade extends AbstractFacade<Status> implements Serializable {

    @PersistenceContext(unitName = "jimdb-warPU")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }

    public StatusFacade() {
        super(Status.class);
    }

    @RolesAllowed("admin")
    @Override
    public void create(Status entity) {
        super.create(entity);
    }

    @RolesAllowed("admin")
    @Override
    public Status edit(Status entity) {
        return super.edit(entity);
    }

    @RolesAllowed("admin")
    @Override
    public void remove(Status entity) {
        super.remove(entity);
    }

    public Status findByMovieStatus(String statusName) {
        return em.createQuery("select s from Status s where s.movieStatus=:statusName", Status.class).setParameter("statusName", statusName).getSingleResult();
    }
}
